<?php
class Action extends admin_abs
{
	function index()
	{
		$data = _model('setting')->getList('ORDER BY id ASC');
		Smarty3::instance()->assign('data', $data);
		Smarty3::instance()->display('h_dev_html/site_update.html');
	}
	function update()
	{
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			
			$bg = _POST('bg');
			$site_name = _POST('site_name');
			$job = _POST('job');
			$idpic = _POST('idpic', 0);
			$idadd = _POST('idadd', 0);
			$idjob = _POST('idjob', 0);
			if (!$idadd) {
				msg('错误参数');
			} 
				_model('setting')->update(array('id'=>$idadd), array('value'=>$site_name));
			if ($bg) {
				_model('setting')->update(array('id'=>$idpic), array('value'=>$bg));
			}
			if ($job) {
				_model('setting')->update(array('id'=>$idjob), array('value'=>$job));
			}
				msg('更新成功', '?url=site');
		} else {
			$id = _GET('id');
			if (empty($id)) {
				msg('参数错误');
			}
			$data = _model('setting')->read(array('id'=>$id));
			Smarty3::instance()->assign('data', $data);
			Smarty3::instance()->display('h_dev_html/site_update.html');
		}
	}
}
?>